import { request, config } from 'utils'
import * as commonService from "utils/services";

const { api } = config;
const { coupons, distributor, salesPaymenter } = api;

export async function query(params = {}) {
  params.apiBaseUrl = `${coupons}`;
  return commonService.commonQuery(params);
}
export async function queryByDistributor(params = {}) {
  params.apiBaseUrl = `${coupons}/distributor`;
  return commonService.commonQuery(params);
}
export async function distributorQuery(params = {}) {
  params.apiBaseUrl = `${distributor}`;
  return commonService.commonQuery(params);
}
export async function add(params = {}) {
  const url = `${coupons}/create`
  return request({ url: url, method: 'POST', data: params })
}
export async function detail(id) {
  const url = `${coupons}/check/${id}/detail`
  return request({ url: url, method: 'GET' })
}
export async function approve(id, params) {
  const url = `${coupons}/${id}/approve`
  return request({ url: url, method: 'POST', data: params })
}
export async function deny(params) {
  const url = `${coupons}/${params.id}/deny`
  return request({ url: url, method: 'POST', data: params.values })
}
export async function listDistributors(params = {}) {
  const url = `${salesPaymenter}/distributor/mine`
  return request({ url: url, method: 'GET' })
}
